$(document).ready(function () {
	// 表单数据
	const formState = {
		company: '',
		user_name: '',
		phone: '',
		tel: '',
		wechat: '',
		email: '',
		qq: '',
		company_url: '',
		address: '',
		no: '',
		industry: '',
		study_type: '',
		info: ''
	};

	// 绑定数据到表单元素
	function bindFormData () {
		Object.keys(formState).forEach(key => {
			$(`[v-model="${key}"]`).val(formState[key]).on('input', function () {
				formState[key] = $(this).val();
			});
		});
	}

	// 表单验证
	function validateForm () {
		// 简单验证示例，实际应用中需要更复杂的验证逻辑
		if (!formState.user_name) {
			alert('请输入姓名');
			return false;
		}
		if (!formState.phone && !formState.tel) {
			alert('请输入手机或电话');
			return false;
		}
		if (!formState.wechat && !formState.qq) {
			alert('微信号与QQ必须填一个');
			return false;
		}
		return true;
	}
	// Handle button click
	$('.button').on('click', function (e) {
		e.preventDefault();
		console.log('售后申请按钮点击');
		// Add your form submission logic here
		window.location.href = $(this).attr('href');
	});

	// Simulate AOS animations
	$('[data-aos]').each(function () {
		$(this).css('opacity', 0);
		setTimeout(() => {
			$(this).animate({ opacity: 1 }, 800);
		}, 200 * $(this).index());
	});

	// Responsive adjustments
	function handleResize () {
		// Add any additional responsive logic here
	}

	$(window).on('resize', handleResize);
	handleResize();

	// 提交表单
	$('#submitBtn').click(function () {
		if (!validateForm()) return;

		$(this).prop('disabled', true).text('提交中...');

		// 模拟API请求
		setTimeout(function () {
			console.log('提交的数据:', formState);
			alert('报名成功，稍后会联系您');

			setTimeout(function () {
				window.location.href = '/';
			}, 1500);

			$('#submitBtn').prop('disabled', false).text('确认申请');
		}, 1000);
	});

	// 初始化表单数据
	bindFormData();
});
